<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body  style="background-color:#FFFAE3">
<div id="div1">
    <div class="layui-fluid" >
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card" style="background-color:#FFFAE3">
                    <p style="color: #0070C0;text-align: center;font-size: large;font-weight: bold;">未编制询价书一览表</p><br>
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" style="text-align: center">
                            <div class="layui-inline">
                                采购计划名称：
                                <div class="layui-input-inline">
                                    <input type="text" name="stockName" id="stockName" autocomplete="off"  placeholder="采购计划名称" class="layui-input" style="background-color: #FFFAE3">
                                </div>
                            </div>
                            <div class="layui-inline">
                                物资名称：
                                <div class="layui-input-inline">
                                    <input type="text" name="stockName" id="stockName1"  placeholder="物资名称" autocomplete="off" class="layui-input" style="background-color: #FFFAE3">
                                </div>
                            </div>
                            <div class="layui-inline">
                                采购类型：
                                <div class="layui-input-inline">
                                    <select name="stockType" id="stockType" style="background-color: #FFFAE3">
                                        <option value="">全部</option>
                                        <option value="公开求购">公开求购</option>
                                        <option value="定向询价">定向询价</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <!--<button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>-->
                                <button class="layui-btn" data-type="reload" id="search">查询</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-table layui-form" id="test" lay-filter="test"></table>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<div id="div2" style="background-color: #FFFAE3">
    <div class="layui-fluid" style="background-color: #FFFAE3">
        <div class="layui-row layui-col-space15" style="background-color: #FFFAE3">
            <div class="layui-col-md12" style="background-color: #FFFAE3">
                <div class="layui-card" style="background-color:#FFFAE3">
                    <div class="layui-card-body layui-table-body layui-table-main" style="background-color: #FFFAE3">
                        <!--<table class="layui-table layui-form" id="test"></table>-->
                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px;background-color: #FFFAE3" cellSpacing=1 cellPadding=0 width="100%"
                               bgColor=#336699 borderColorLight=#006699 border=0>
                            <TBODY style="background-color: #FFFAE3">
                            <TR style="background-color: #FFFAE3">
                                <TD style="background-color:#FFFAE3">
                                    <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0 style="background-color: #FFFAE3">
                                        <TBODY style="background-color: #FFFAE3">
                                        <TR bgColor=#ffffff>
                                            <TD align=middle width="100%" style="background-color: #FFFAE3" colSpan=20
                                                height=22>
                                                <H2 style="color:#0070c0 "><B>编制询价书</B> </H2>
                                                <A
                                                        onclick="window.open('../help/Help.asp?Value=询价书明细信息','child','status=NO,scrollbars=yes,toolbar=no,menubar=no,location=no,left=200,top=100,width=700,height=400')"
                                                        href="javascript:void(null)">
                                                </A>
                                                </FONT></H2></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%" hidden>询价书序号</TD>
                                            <TD class=t2 noWrap id="id" hidden></TD>
                                            <TD noWrap width="20%">询价书编号</TD>
                                            <TD class=t2 noWrap id="enquireNum"></TD>
                                            <TD noWrap width="20%">询价书名称</TD>
                                            <TD class=t2 noWrap><input type="text" id="enquireName" name="enquireName" style="background-color: #FFFAE3"></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">单位</TD>
                                            <TD class=t2 noWrap id="company"></TD>
                                            <TD noWrap width="20%">联系人</TD>
                                            <TD class=t2 noWrap><input type="text" id="linkman" name="linkman" style="background-color: #FFFAE3"></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">联系地址</TD>
                                            <TD class=t2 noWrap><input type="text" id="address" name="address"  style="background-color: #FFFAE3"/></TD>
                                            <TD noWrap width="20%">联系电话</TD>
                                            <TD class=t2 noWrap><input type="text" id="phone" name="phone" style="background-color: #FFFAE3" /></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">联系传真</TD>
                                            <TD class=t2 noWrap><input type="text" id="fax" name="fax" style="background-color: #FFFAE3" /></TD>
                                            <TD noWrap width="20%">邮编</TD>
                                            <TD class=t2 noWrap><input type="text" id="zip" name="zip"style="background-color: #FFFAE3" /></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">Email</TD>
                                            <TD class=t2 noWrap><input type="text" id="email" name="email"style="background-color: #FFFAE3" /></TD>
                                            <TD noWrap width="20%">报价截止时间</TD>
                                            <TD class=t2 noWrap><input type="date" id="endDate" name="endDate"style="background-color: #FFFAE3" />
                                            </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
                        <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=0 width="100%" bgColor=#ffffff
                               borderColorLight=#ffffff border=0>
                            <TBODY>
                            <TR>
                                <TD style="background-color:#FFFAE3">
                                    <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%"
                                           border=0><B>我公司欲采购下述物资，如贵单位有兴趣，可参与网上报价。详细物资情况如下：</B>
                                        <TBODY></TBODY></TABLE></TD></TR></TBODY></TABLE>
                        </table></td></tr></table>

                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 id="tableEnq"     width="100%"  bgColor=#336699 borderColorLight=#006699 border=0>

                        </table>

                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0     width="100%"  bgColor=#336699 borderColorLight=#006699 border=0>
                            <tr>
                                <td bgcolor="#FFFAE3">
                                    <table cellpadding="3" cellspacing="1" border="0" width="100%">
                                        <tr class="t2" bgcolor="#FFFFFF">
                                            <td nowrap>询价说明</td>
                                            <td colspan="3" style="width:100%"><textarea name="textarea" rows="4" id="remark" style="width:100%"></textarea></td>
                                        </tr>
                                    </table></td></tr></table>

                        </form>
                        <script Language="JavaScript" src="js/pub_Calendar.js"></script>
                        <script language="javascript">
                            function QuotePrint(p_QuoteNo)
                            {
                                window.open("Quote_Print.ASP?QuoteNo="+p_QuoteNo,"","toolbar=0,resizable=yes,location=0,status=0,menubar=1,scrollbars=1,width=800,height=600,left=0,top=0");
                            }
                        </script>
                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%"
                               bgColor=#336699 borderColorLight=#006699 border=0>
                            <TBODY>
                            <TR>
                                <TD>
                                    <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>
                                        <TBODY>
                                        </TBODY></TABLE></TD></TR></TBODY></TABLE><BR></FORM>
                        <P align=right><BR><B id="gsi">株洲南车时代电气股份有限公司</B>
                        <CENTER><BR>
                            <button value="确定" onclick="updateE()">确定</button>
                            <button value="返回" onclick="rturn()">返回</button>
                        </CENTER>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script id="button" type="text/html">
    <a class="layui-btn layui-btn-xs" lay-event="BianZhi">编制</a>
    <a class="layui-btn layui-btn-xs" href="javascript:history.back()">返回</a>
</script>
<script>
    var stockName='';
    layui.use('table', function(){
        $("#div2").hide();
        var table = layui.table;
        table.render({
            elem: '#test'  //html中渲染table的id
            , url: '/stock/'   //后台获取数据集合的地址
            , cellMinWidth: 80
            , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                , groups: 1 //只显示 1 个连续页码
                , first: false//不显示首页
                , last: false //不显示尾页

            }, cols: [
                [
                    //表单显示的title以及返回的需要显示的数据，field值与获取集合中的类的字段名一致。
                    // {title: '选择', type:'radio',id:"radio" , align: 'center',width: 80},
                    {field: 'id', title: '序号', align: 'center',width:80},
                    {field: 'stockName', title: '采购计划名称', align: 'center',width: 150},
                    {field: 'stockType', title: '采购类型', align: 'center'},
                    {field: 'submitDate', title: '采购计划下达时间', align: 'center'},
                    {field: 'endDate', title: '计划报价截止时间', align: 'center'},
                    {title: '操作', toolbar: "#button",align:'center', width:170}
                ]
            ],id:'tableAll',

        });
        table.on('tool(test)',function (obj) {
            let data=obj.data;
            //alert(JSON.stringify(data));
            if(obj.event="BianZhi"){
                stockName=data.stockName;
                $("#div1").hide();
                $("#div2").show();
                $.ajax({
                    url: "/Enquire/Sel",
                    data:{
                        "id":data.id,
                    },
                    type: "POST",
                    success: function (result) {
                        $("#id").html(result.id);
                        $("#company").html("长沙北大青鸟有限公司");
                        $("#enquireNum").html(result.enquireNum);
                        var orders=result.stock.orders;
                        for (let i = 0; i < orders.length; i++) {
                            $("#tableEnq").append(
                                "<tr style='background-color: #FFFAE3' >\n" +
                                "                                <td bgcolor=\"#FFFAE3\">\n" +
                                "                                    <table  cellpadding=\"3\" cellspacing=\"1\" border=\"0\" width=\"100%\" id=\"datatable\" >\n" +
                                "\n" +
                                "                                        <tr>\n" +
                                "                                            <td colspan=6 align=\"middle\" bgcolor=\"#99ccff\"><B>需求计划"+orders[i].id+"</td>\n" +
                                "                                        </tr>\n" +
                                "                                        <tr class=t2 bgcolor=\"#FFFFFF\">\n" +
                                "                                            <td >物资编码</td>\n" +
                                "                                            <td >"+orders[i].materialCode+"<br></td>\n" +
                                "                                            <td >物资名称</td>\n" +
                                "                                            <td >"+orders[i].materialName+"<br></td>\n" +
                                "                                            <td ></td>\n" +
                                "                                            <td ></td>\n" +
                                "                                        </tr>\n" +
                                "                                        <tr class=t2 bgcolor=\"#FFFFFF\">\n" +
                                "                                            <td >计量单位</td>\n" +
                                "                                            <td >"+orders[i].measureUnit+"<br></td>\n" +
                                "                                            <td ></td>\n" +
                                "                                            <td ></td>\n" +
                                "                                            <td ></td>\n" +
                                "                                            <td ></td>\n" +
                                "                                        </tr>\n" +
                                "\n" +
                                "                                        <tr bgcolor=\"#FFFFFF\">\n" +
                                "                                            <td nowrap >单价(元/含税)</td>\n" +
                                "                                            <td nowrap ><input name=\"\" type=\"text\" value="+orders[i].unitPrice+"></td>\n" +
                                "                                            <td nowrap >数量</td>\n" +
                                "                                            <td nowrap ><input type='text' name='' value="+orders[i].amount+"/></td>\n" +
                                "                                            <td nowrap >总价(元/含税)</td>\n" +
                                "                                            <td nowrap >"+(orders[i].unitPrice*orders[i].amount)+"</td>\n" +
                                "                                        </tr>\n" +
                                "\n" +
                                "                                        <tr bgcolor=\"#FFFFFF\">\n" +
                                "                                            <td nowrap >报价开始时间</td>\n" +
                                "                                            <td nowrap ><input name=\"\"  type=\"date\"  value="+orders[i].startDate+"></td>\n" +
                                "                                            </td>\n" +
                                "                                            <td nowrap >报价截止时间</td>\n" +
                                "                                            <td nowrap ><input name=\"\" type=\"date\"  value="+orders[i].endDate+"></td>\n" +
                                "                                            <td nowrap ></td>\n" +
                                "                                            <td nowrap ></td>\n" +
                                "                                            </td>\n" +
                                "                                        </tr>\n" +
                                "\n" +
                                "                                    </table></td></tr>"
                            );
                        }
                    }
                });
            }

        })
        $('#search').on('click', function(){
            table.reload('tableAll', {
                method : 'get',
                /*url:'/contractmanager/byName',//这个不写表示使用table中的请求*/
                where : {
                    stockName : $.trim($('#stockName').val()),
                    stockName : $.trim($('#stockName1').val()),
                    stockType : $.trim($('#stockType').val())
                },
                page : {
                    curr : 1
                }
            });
            return false;
        });

    });
    function rturn() {
        var id =$("#id").html();
        $.ajax({
            url:"/Enquire/del",
            method: "post",
            data: {"id":id},
            success:function (result) {
                if(result>0){
                    location.href="/queryandqueto/Project_list.html";
                }
            }
        })
    }
    function updateE() {
        var id = $("#id").html();
        var enquireNum=$("#enquireNum").html();
        var enquireName=$("#enquireName").val();
        var company=$("#company").html();
        var linkman=$("#linkman").val();
        var address=$("#address").val();
        var phone=$("#phone").val();
        var fax=$("#fax").val();
        var zip=$("#zip").val();
        var email=$("#email").val();
        var endDate=$("#endDate").val();
        var remark=$("#remark").val();
        $("#gsi").html(company);
        if( id==null && id=='' ||
            enquireNum==null && enquireNum=='' ||
            enquireName==null && enquireName=='' ||
            company==null && company=='' ||
            linkman==null && linkman==''||
            address==null && address==''||
            phone==null && phone==''||
            fax==null && fax==''||
            zip==null && zip==''||
            email==null && email=='' ||
            endDate==null && endDate==''||
            remark==null && remark==''){
            layer.alert("未填写！");
        }else{
            $.ajax({
                url: "/Enquire/updateEnquire",
                data: {
                    "stockName":stockName,
                    "id": $.trim(id),
                    "enquireNum": $.trim(enquireNum),
                    "enquireName": $.trim(enquireName),
                    "company": $.trim(company),
                    "linkman": $.trim(linkman),
                    "address":$.trim(address),
                    "phone": $.trim(phone),
                    "fax":$.trim(fax),
                    "zip": $.trim(zip),
                    "email":$.trim(email),
                    "endDate": $.trim(endDate),
                    "remark": $.trim(remark)
                },
                type: "post",
                success: function (result) {
                    if ($.trim(result) == "true") {
                        location.href="/queryandqueto/Project_list.html";
                    }
                }
            });
        }
    }
</script>

</html>